//关键词高亮过滤器
const filterKeyword = function(string, keyword) {
  keyword = keyword.replace(/(^\s*)|(\s*$)/, '');
  if (!string || !keyword) {
    return string;
  }
  keyword = keyword.replace(/\s+/g, ' ');
  var keys = keyword.split(' ');
  for ( var i in keys) {
    var reg = new RegExp(keys[i], 'g');
    var em = '<em>' + keys[i] + '</em>';
    string = string.replace(reg, em);
  }
  return string;
}

export {filterKeyword}